<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 

<div class="container-fluid">
<table class="table table-striped table-bordered table-hover dataTable" id="sample_2" aria-describedby="sample_2_info">
	<thead>
		<tr>
            <th style="width: 70px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">菜品图片</th>
			<th style="width: 70px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">菜品名称</th>
			<th style="width: 24px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">类别</th>
			<th style="width: 24px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">价格</th>
			<th style="width: 24px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">当前状态</th>
			<th style="width: 24px;" class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="">操作</th>
		 
		</tr>
	</thead>
	<c:forEach var="dish" items="${dishlist}">
		<tbody>
			<tr>
			    <td><a href="/houtai/dish/edit.do?dishCode=${dish.dishCode}"><img src="${dish.imageMain}" alt=""
											id="imagepreview" style="width: 200px; height: 150px;" /></a></td>
				<td>${dish.dishName}</td>
				<td>${dish.dishGroup}</td>
				<td>${dish.dishPrice}</td>
				<c:if test="${dish.onSale=='1'}"><td style="background-color: green">在售</td></c:if> 
				<c:if test="${dish.onSale=='0'}"><td style="background-color: red;">停售</td></c:if>
				
				<td><c:if test="${dish.onSale=='1'}"><div class="btn btn-primary"
							onClick="updateDishStatus('${dish.dishCode}','onSale','0')">停售</div></c:if> 
			        <c:if test="${dish.onSale=='0'}"><div class="btn btn-primary"
							onClick="updateDishStatus('${dish.dishCode}','onSale','1')">重新售卖</div></c:if> 
							<div class="btn btn-primary"
							onClick="updateDishStatus('${dish.dishCode}','isDelete','1')">下架</div>
				</td>
			</tr>
		</tbody>
	</c:forEach>


</table>
<script>
 function updateDishStatus(dishCode,key,value){
	 //alert(dishCode+'---'+key+'---'+value); 
	 var url="/houtai/dish/changestatus.do";
	 var param = new Object();
	 param.dishCode=dishCode;
	 param.key=key;
	 param.value=value;
	  
	 var oo = {};
	 oo.url=url;
	 oo.params=JSON.stringify(param);
	 oo.success=function(data){
	  window.location.reload();
	 };
	 oo.error=function(){
		 alert("系统错误，更新失败");
	 }
	 sendRequest(oo);
 }
 
 
</script>
</div>